<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/8/31 0031
  Time: 13:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="jquery3.js"></script>
    <script>
        $(function () {
            let params = new URLSearchParams(location.search);
            let page = params.get("page");
            if (page == null) {
                page = 1;
            }
            let size = params.get("size");
            if (size == null) {
                size = 2;
            }

            $.post("user", {action: "list", "page": page, "size": size}, function (data) {
                let json = $.parseJSON(data);
                json.forEach(function (zhi) {
                    $("#tab").append(" <tr> " +
                        "<td>" + zhi.id + "</td>" +
                        " <td>" + zhi.name + "</td> " +
                        "<td>" + zhi.sex + "</td> " +
                        "<td>" + zhi.age + "</td> " +
                        "<td>" + zhi.adult + "</td> " +
                        "<td>详情&nbsp;&nbsp;" +
                        "<span style='cursor: pointer' class='del' id='" + zhi.id + "'>删除</span></td> " +
                        "</tr>");
                });
            })
            $("#tab").on("click", ".del", function () {
                let b = confirm("确认删除??");
                if (b == true) {
                    $.post("user", {
                        action: "del",
                        "id": this.id
                    }, function (data) {
                        let json = $.parseJSON(data);
                        if (json.stues) {
                            alert("删除成功");
                            location.href = "liebiao.jsp";
                        } else {
                            alert("删除失败");
                        }
                    });
                }
            })
        });

    </script>
    <style>
        #main {
            height: 400px;
            width: 700px;
            margin: 0px auto;
        }

        table {
            height: 400px;
            width: 700px;
            border: 1px solid black;
        }

        tr {
            border: 1px solid black;
        }

        td {
            width: 30px;
            height: 50px;
            border: 1px solid black;
        }

        #wezi {
            width: 40px;
            height: 50px;
        }
    </style>
</head>
<body>
<div id="main">
    <table>
        <tr>
            <td>id</td>
            <td>酒店名称</td>
            <td id="wezi">位置</td>
            <td>介绍</td>
            <td>价格</td>
            <td>房间名称</td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>

    </table>
    总页数:<%=pagecount %>/当前页数<%=in %>
    <a href="jj.jsp?index=<%=in-1==0?1:in-1 %>">上一页</a>
    <% for(int i=1;i<=pagecount;i++){ %>
    <a href="jj.jsp?index=<%=i %>"><%=i %></a>&nbsp;
    <%} %>
    <a href="jj.jsp?index=<%=in+1>pagecount?pagecount:(in+1) %>">下一页</a>
    <input id="vv" value="<%=in %>" type="text" style="width: 30px;">
    <input onclick="tz();" type="button" value="跳转">
</div>
</body>
</html>
